package it.virtuscarroccio.com.service.impl;

import it.virtuscarroccio.com.dao.NewsDAO;
import it.virtuscarroccio.com.model.News;
import it.virtuscarroccio.com.model.NewsExample;
import it.virtuscarroccio.com.service.NewsManager;

import java.util.List;

public class NewsManagerImpl implements NewsManager{

	private NewsDAO newsDao;
	
	public void setNewsDao(NewsDAO newsDao) {
		this.newsDao = newsDao;
	}

	@SuppressWarnings("unchecked")
	public List<News> getAllNews() {
		NewsExample n = new NewsExample();
		n.setOrderByClause("date_creation desc");
		return newsDao.selectByExampleWithBLOBs(n);
	}

	public News getNews(Integer id) {
		return newsDao.selectByPrimaryKey(id);
	}

	public void deleteNews(Integer id) {
		newsDao.deleteByPrimaryKey(id);
	}

	public void updateNews(News news) {
		newsDao.updateByPrimaryKeySelective(news);
	}
	
	public void insertNews(News news){
		newsDao.insert(news);
	}

	

	
	
	
}
